﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Caixa.BLL;
using Caixa.Model;

namespace Caixa
{
	public partial class Frm_Base : Form
	{
		#region " Constructor "

		public Frm_Base()
		{
			InitializeComponent();
		}

		#endregion

		#region " Properts "

		private bool LoadedDadosConta { get; set; }

		#endregion

		#region " Events "

		private void Frm_Base_Load(object sender, EventArgs e)
		{
			LoadDadosConta();
		}

		private void Frm_Base_Activated(object sender, EventArgs e)
		{
			if (!this.LoadedDadosConta)
				LoadDadosConta();
		}

		private void Frm_Base_KeyDown(object sender, KeyEventArgs e)
		{
			if ((!this.Name.ToUpper().Equals("FRM_INICIAL")) && e.KeyCode.Equals(Keys.Escape))
			{
				this.Close();
			}
		}

		#endregion

		#region " Methods "

		private void LoadDadosConta()
		{
			pnlDadosConta.Visible = CaixaEletronicoBLL.IsLogado;
			if (pnlDadosConta.Visible)
			{
				Agencia a = AgenciaBLL.GetByID(CaixaEletronicoBLL.ContaLogada.IDAgencia);
				if (a != null)
					lblAgencia.Text = a.Numero.ToString();
				lblConta.Text = CaixaEletronicoBLL.ContaLogada.Numero.ToString();

				this.LoadedDadosConta = true;
			}
		}

		#endregion
	}
}
